﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FortuneHeaven.Admin.Common;
using FortuneHeavenBAL;
using FortuneHeavenCommon.DataMap;

namespace FortuneHeaven.Admin.Pages.GameManager
{
    public partial class RoomInforList : FortuneHeaven.Admin.Common.PageBase
    {
        public override string PageID
        {
            get { return "F52"; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            lblDeptName.Text = "房间信息";
            this.usPager.PagerChanged += new Admin.Controls.Pagination.PagerChangeHandler(usPager_PagerChanged);
            if (!this.IsPostBack)
            {
                this.drpPagerSize.Items.Clear();
                this.drpPagerSize.Items.Add(new ListItem("每页10行", "10"));
                this.drpPagerSize.Items.Add(new ListItem("每页20行", "20"));
                this.drpPagerSize.Items.Add(new ListItem("每页50行", "50"));

                //if (!string.IsNullOrEmpty(Request["orderid"]))
                //{
                //    this.txtOrderID.Text = Request["orderid"];
                //}
               
                if (!AuthorityCenter.IsAdmin)
                {
                    AdminUserBO userbo = new AdminUserBO();
                    AdminUser user = userbo.GetInfo(AuthorityCenter.CurrentUserID);
                    this.txtOrderID.Text = user.RoomFilter;
                    this.txtOrderID.Visible = false;
                    this.btnSearch.Visible = false;
                }

                if (!string.IsNullOrEmpty(Request["pagesize"]))
                {
                    this.drpPagerSize.SelectedIndex = int.Parse(Request["pagesize"]);
                }
                else
                {
                    this.drpPagerSize.SelectedValue = "10";
                }

                if (!string.IsNullOrEmpty(Request["current"]))
                {
                    ResetList(int.Parse(Request["current"]));
                }
                else
                {
                    ResetList();
                }
                //this.lvNews.ItemCommand += new EventHandler<ListViewCommandEventArgs>(lvNews_ItemCommand);

            }
        }
        private void usPager_PagerChanged(object sender, int currentpage)
        {
            Refresh();
        }

        public void Refresh()
        {
            animalrecordBO giftorder = new animalrecordBO();
            
            lvNews.DataSource = giftorder.GetGroupList(this.usPager.CurrentPageIndex, int.Parse(this.drpPagerSize.SelectedValue), this.txtOrderID.Text);
            lvNews.DataBind();
        }

        protected void drpPagerSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            ResetList();
        }

        public void ResetList()
        {
            ResetList(1);
        }

        public void SearchValue(object sender, EventArgs e)
        {
            ResetList();
        }

        public void ResetList(int current)
        {
    
            animalrecordBO giftorder = new animalrecordBO();
            this.usPager.RecordCount = giftorder.GetGroupTotalSize(this.txtOrderID.Text);
            this.usPager.PageSize = int.Parse(this.drpPagerSize.SelectedValue);
            this.usPager.Initial();
            this.usPager.CurrentPageIndex = 1;
        }
        public long GetTotal(object left, object cotain)
        {
            int first = 0;
            Int64 second = 0;
            if (left != null && left is int)
            {
                first = (int)left;
            }
            if (cotain != null && cotain is Int64)
            {
                second = (Int64)cotain;
            }
            return (long)first + (long)second;

        }
    }

}